<?php

/**
 * Description of OverlayUploadForm
 *
 * @author jahid
 */
class OverlayUploadForm extends BaseFormDoctrine {

    public function setup() {
        $this->setWidgets(array(
            'upload' => new sfWidgetFormInputFileEditable(array(
                            'file_src' => '/' . basename(sfConfig::get('sf_upload_dir')) . '/' . $this->getObject()->getOverlaytitle(),
                            'is_image' => true,
                            'edit_mode' => strlen($this->getObject()->getOverlaytitle()) > 0,
                            'template' => '
                                <div>%file%
                                %input%
                                %delete% %delete_label%</div>'
                        ))
        ));

        $this->setValidators(array(
            'upload' => new sfValidatorFile(array(
                            'required' => false,
                            'mime_types' => 'web_images'
                        )),
            'upload_delete' => new sfValidatorPass()
        ));

        $this->widgetSchema->setNameFormat('uploadoverlay[%s]');

        $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

        $this->setupInheritance();

        parent::setup();
    }

    public function getModelName() {
        return 'Researchoverlay';
    }
}

